Page({
  data: {
    items: [
      { name: 'qq', value: 'QQ' },
      { name: 'wechat', value: '微信', checked: true},
      { name: 'phone_num', value: '电话号码' },
    ],
  },

  onLoad() {},
  // 上传照片
  chooseImage() {
    my.chooseImage({
      sourceType: ['camera','album'],
      count: 9,
      success: (res) => {
        my.alert({
          content: JSON.stringify(res),
        });
      },
      fail:()=>{
        my.showToast({
          content: '上传失败', // 文字内容
        });
      }
    })
  },
  onSubmit() {},

  // 选择联系方式后生成输入框
  onChange:function(e) {
    const checked = e.detail.value;
    const index = e.currentTarget.dataset.index;

    // 更新对应项的状态
    const items = this.data.items;
    items[index].checked = checked;

    this.setData({
      items: items,
    });
  }
});
